package com.renren.project.db.bean;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


@ApiModel("分页查询参数对象")
@Data
public class PageInfo {

    @ApiModelProperty(value = "页码")
    private Integer num = 1;


    @ApiModelProperty(value = "条数")
    private Integer size = 10;

    @ApiModelProperty(hidden = true)
    private boolean max;

    public static PageInfo maxSize() {
        PageInfo pageInfo = new PageInfo();
        pageInfo.setSize(Integer.MAX_VALUE);
        pageInfo.max = true;
        return pageInfo;
    }

    public Page page() {
        if (num == null || num < 0) {
            num = 1;
        }
        if (!max) {
            if (size == null || size < 0 || size > 100) {
                size = 10;
            }
        }
        return new Page<>(num, size);
    }
}




